//
//  TT_JumpManager.m
//  BaseProject
//
//  Created by 王洋 on 2020/5/29.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "TT_JumpManager.h"


@implementation TT_JumpManager

+ (TT_JumpManager *)sharedManager {
    static TT_JumpManager *shareInstance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken,^{
        shareInstance = [TT_JumpManager new];
    });
    return shareInstance;
}

- (void)jumpWithPayload:(NSString *)payload {
    
    NSMutableDictionary *payloadDic = @[].mutableCopy;
    payloadDic = [self convert2DictionaryWithJSONString:payload].mutableCopy;
    
    TT_JumpModel * payloadModel = [TT_JumpModel mj_objectWithKeyValues:payloadDic];
    [self jumpWithModel:payloadModel];
}

- (void)jumpWithWebParamDic:(NSDictionary *)dic {
    
    TT_JumpModel * webJumpModel = [TT_JumpModel mj_objectWithKeyValues:dic];
    
    if (webJumpModel.type == TT_JUMPTYPE_IM_COVDETAIL) {
        
    } else {

        [self jumpWithModel:webJumpModel];
    }
}

- (NSDictionary *)convert2DictionaryWithJSONString:(NSString *)jsonString{
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
                                                        options:NSJSONReadingMutableContainers
                                                          error:&err];
    if(err)
    {
        NSLog(@"%@",err);
        return nil;
    }
    return dic;
}

- (void)jumpWithModel:(TT_JumpModel *)jumpModel {
    
    TT_NavigationViewController *navController = (TT_NavigationViewController *)[TT_TabbarViewController shareTabbar].selectedViewController;
    
    switch (jumpModel.type) {

        case TT_JUMPTYPE_AITracking:{

            
        } break;
            
        default:{
            
            
        } break;
    }
}

@end
